import TreeTraversal.TreeNode;

public class isSymmetric {
    public boolean isSymmetric(TreeNode root) {
        return check(root.left,root.right);
    }
    public boolean check(TreeNode left,TreeNode right){
        if(left == null && right == null){
            return true;
        }
        if(left == null && right != null){
            return false;
        }
        if(left != null && right == null){
            return false;
        }
        if(left.val != right.val){
            return false;
        }
        boolean a = check(left.left,right.right);
        boolean b = check(left.right,right.left);
        return a&b;
    }
}
